package org.jsping.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jsping.service.IHailFellowService;
import org.jsping.service.impl.HailFellowServiceImpl;

import com.alibaba.fastjson.JSONArray;

/**
 * 处理好友列表请求的servlet
 */
@WebServlet("/HailFellowServlet")
public class HailFellowServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	IHailFellowService hail = new HailFellowServiceImpl();
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int id = Integer.valueOf(request.getParameter("id"));
		
		/*根据Id来获取好友列表*/
		JSONArray array = hail.getHailFellowList(id);
		PrintWriter pw = response.getWriter();
		pw.print(array);
		pw.flush();
		pw.close();
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
